package org.maylove.wuziqi.dao;

import jakarta.transaction.Transactional;
import org.maylove.wuziqi.pojo.discuss.discussBody.DiscussBody;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DiscussBodyDao extends JpaRepository<DiscussBody, Long> {
    DiscussBody findByDiscussBodyId(Long discussBodyId);

    @Transactional
    @Modifying
    void deleteByDiscussBodyId(Long discussBodyId);

    @Query("SELECT d FROM DiscussBody d WHERE d.discussId=?1 ORDER BY d.discussBodyId")
    List<DiscussBody> getDiscussBody(Long discussId);
}
